package com.xbongbong.pro.statistic.pojo;

import com.xbongbong.paas.toolbox.util.BeanUtil;
import com.xbongbong.pro.domain.entity.ChartEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.collections4.CollectionUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zyy
 * @date 2022/11/30/ 17:27:00
 * @since v1.0
 */
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class LinkageListPojo implements Serializable {
    private static final long serialVersionUID = 6744556763884163219L;

    /**
     *  图表主键id
     */
    private Long id;
    /**
     *  图表名称
     */
    private String name;
    /**
     *  图表类型
     */
    private Integer statisticsType;
    /**
     *  图表type
     */
    private Integer chartType;
    /**
     *  图表所在分类id
     */
    private Long categoryId;
    /**
     *  图表唯一标识
     */
    private String uuid;
    /**
     *  是否已被选中
     */
    private Boolean checked = Boolean.FALSE;

    /**
     * 将图表实体类型转换为对应的pojo
     *
     * @param sameSourceChartList 可选被联动图表数组
     * @return java.util.List<com.xbongbong.pro.statistic.pojo.LinkageListPojo>
     * @author zyy
     * @date 2022/12/1
     * @version v1.0
     */
    public static List<LinkageListPojo> linkageDataFormat(List<ChartEntity> sameSourceChartList) {
        if(CollectionUtils.isEmpty(sameSourceChartList)){
            return new ArrayList<>();
        }
        List<LinkageListPojo> resultPojo = new ArrayList<>();
        sameSourceChartList.forEach(chartEntity -> {
            LinkageListPojo linkageListPojo = new LinkageListPojo();
            BeanUtil.copyProperties(chartEntity,linkageListPojo);
            resultPojo.add(linkageListPojo);
        });
        return resultPojo;
    }
}
